﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace YXShop.Web.membercenter.individualinfo
{
    public partial class memberinfo_show : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                if (Session["MemberID"] != null)
                {   
                    string memberId = Session["MemberID"].ToString();
                    GetAccountById(Convert.ToInt32(memberId));
                    GetInfoById(Convert.ToInt32(memberId));   
                    InitWebControl(Convert.ToInt32(memberId));
                }                         
            }
        }

        private void InitWebControl(int uid)
        {
            string url=YXShop.TemplateAction.Common.UrlStr("order_center", "", "membercenter/order/");
            this.linklist.Text += "<li><img src=\"../../images/mem_img5.jpg\" alt=\"\"/>&nbsp;<a href=\"" + url + "\">订单信息</a></li>";
            this.linklist.Text += "<li><img src=\"../../images/mem_img5.jpg\" alt=\"\"/>&nbsp;<a href=\"fundlist.aspx?uid=" + uid + "\">资金明细</a></li>";
            this.linklist.Text += "<li><img src=\"../../images/mem_img5.jpg\" alt=\"\"/>&nbsp;<a href=\"volumelist.aspx?uid=" + uid + "\">点卷明细</a></li>";
            this.linklist.Text += "<li><img src=\"../../images/mem_img5.jpg\" alt=\"\"/>&nbsp;<a href=\"usefullist.aspx?uid=" + uid + "\">有效期明细</a></li>";
            this.linklist.Text += "<li><img src=\"../../images/mem_img5.jpg\" alt=\"\"/>&nbsp;<a href=\"changeuseful.aspx?uid=" + uid + "\">兑换有效期</a></li>";
            this.linklist.Text += "<li><img src=\"../../images/mem_img5.jpg\" alt=\"\"/>&nbsp;<a href=\"changevolume.aspx?uid=" + uid + "\">兑换点卷</a></li>";
            this.linklist.Text += "<li><img src=\"../../images/mem_img5.jpg\" alt=\"\"/>&nbsp;<a href=\"changecalorie.aspx\">充值卡充值卡</a></li>";
            this.linklist.Text += "<li><img src=\"../../images/mem_img5.jpg\" alt=\"\"/>&nbsp;<a href=\"mail_list.aspx?uid=" + uid + "\">我的短消息</a></li>";
            this.linklist.Text += "<li><img src=\"../../images/mem_img5.jpg\" alt=\"\"/>&nbsp;<a href=\"rework_password.aspx\">修改密码</a></li>";
            this.linklist.Text += "<li><img src=\"../../images/mem_img5.jpg\" alt=\"\"/>&nbsp;<a href=\"memberinfo_edit.aspx\">修改信息</a></li>";
        }

        private void GetAccountById(int id)
        {
            YXShop.BLL.Member.MemberAccount accountBll = new YXShop.BLL.Member.MemberAccount();
            YXShop.Model.Member.MemberAccount model = accountBll.GetModel(id);
            if(model!=null)
            {
                this.lblUserId.Text = "【" + model.UserId + "】";
                this.lblUserType.Text = ChangeHope.DataBase.DataHelper.GetContent("yxs_code_usertype", model.UserType.ToString());
                this.lblUserGroup.Text = ChangeHope.DataBase.DataHelper.GetContent("yxs_memberrank", "Id", "Name", model.UserGroup.ToString());
                this.lblUserId.Text = model.UserId;
                this.lblEmail.Text = model.Email;
                this.lblState.Text = model.State == 1 ? "被冻结" : "正常";
                this.lblRegisterDate.Text = model.RegisterDate.ToString();
                this.lblRegisterIP.Text = model.RegisterIP;
                this.lblLastLoginDate.Text = model.LastLoginDate.ToString();
                this.lblLastLoginIP.Text = model.LastLoginIP;
                this.lblCapital.Text = model.Capital.ToString();
                this.lblCoupons.Text = model.Coupons.ToString();
                this.lblPoints.Text = model.Points.ToString();
                this.lblPeriodOfValidity.Text = model.PeriodOfValidity.ToString();
            }
        }

        private void GetInfoById(int id)
        {
            YXShop.BLL.Member.MemberInfo infoBll = new YXShop.BLL.Member.MemberInfo();
            YXShop.Model.Member.MemberInfo model = infoBll.GetModel(id);
            if(model!=null)
            {
                this.lblTrueName.Text = model.TrueName + "(籍贯：" + model.Origin + ")";
                this.lblTitle.Text = model.Title;
                this.lblBirthday.Text = (model.Birthday != null ? (((DateTime)model.Birthday).ToString("yyyy-MM-dd")) : ("未填写"));
                this.lblPapersType.Text = ChangeHope.DataBase.DataHelper.GetContent("yxs_code_papers", model.PapersType);
                this.lblPapersNumber.Text = model.PapersNumber;
                this.lblNation.Text = model.Nation;
                this.lblSex.Text = ChangeHope.DataBase.DataHelper.GetContent("yxs_code_sex", model.Sex.ToString());
                this.lblMarriage.Text = ChangeHope.DataBase.DataHelper.GetContent("yxs_code_marriage", model.Marriage.ToString());
                this.lblEducation.Text = ChangeHope.DataBase.DataHelper.GetContent("yxs_code_education", model.Education);
                this.lblGraduateSchool.Text = model.GraduateSchool;
                //获取省信息
                string province = "";
                BLL.SystemInfo.Provinces bllProvinces = new YXShop.BLL.SystemInfo.Provinces();
                Model.SystemInfo.Provinces modelProvinces = bllProvinces.GetModel(ChangeHope.Common.StringHelper.StringToInt(model.Province));
                if (modelProvinces != null)
                {
                    province = modelProvinces.CityName;
                }
                modelProvinces = bllProvinces.GetModel(ChangeHope.Common.StringHelper.StringToInt(model.City));
                if (modelProvinces != null)
                {
                    province = province + "." + modelProvinces.CityName;
                }
                modelProvinces = bllProvinces.GetModel(ChangeHope.Common.StringHelper.StringToInt(model.Borough));
                if (modelProvinces != null)
                {
                    province = province + "." + modelProvinces.CityName;
                }
                this.lblProvince.Text = province;
                this.lblAddress.Text = model.Address;
                this.lblZip.Text = model.Zip;
                this.lblOfficePhone.Text = model.OfficePhone;
                this.lblHomePhone.Text = model.HomePhone;
                this.lblMobilePhone.Text = model.MobilePhone;
                this.lblHandPhone.Text = model.HandPhone;
                this.lblFax.Text = model.Fax;
                this.lblPersonWebSite.Text = model.PersonWebSite;
                this.lblQQ.Text = model.QQ;
                this.lblMSN.Text = model.MSN;
                this.lblICQ.Text = model.ICQ;
                this.lblUC.Text = model.UC;
                this.lblLifeHobbies.Text = model.LifeHobbies;
                this.lblCultureHobbies.Text = model.CultureHobbies;
                this.lblEntertainment.Text = model.Entertainment;
                this.lblSportsHobbies.Text = model.SportsHobbies;
                this.lblOtherHobbies.Text = model.OtherHobbies;
                this.lblIncName.Text = model.IncName;
                this.lblDepartment.Text = model.Department;
                this.lblPositions.Text = model.Positions;
                this.lblWorkRange.Text = model.WorkRange;
                this.lblIncAddress.Text = model.IncAddress;
                this.lblMonthlyInCome.Text = model.MonthlyInCome + " 元人民币";
            }
        }
    }
}
